<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<div class="x-breadcrumb-wrapper" style="margin-top:20px;">
  <div class="x-breadcrumb yellow clearfix">
    <h2>
      <span>课程列表</span>
    </h2>
  </div>
</div>

<table class="table table-striped table-hover x-table" style="margin-bottom:20px;">
  <thead>
    <tr>
      <th>课程名称</th>
      <th>课时</th>
      <th>课件属性</th>
      <th>教练&nbsp;/&nbsp;门店</th>
      <th>开启&nbsp;/&nbsp;冻结&nbsp;/&nbsp;过期</th>
      <th>状态</th>
      <th class="text-center">操作</th>
    </tr>
  </thead>
  <tbody>
    <c:forEach var="courseRound" items="${courseRounds}">
      <tr>
        <td>${courseRound.course.name}</td>
        
        <c:choose>
          <c:when test="${status == 'scheduling'}">
            <td>
              <c:choose>
                <c:when test="${not empty courseRound.attrs['course_amount']}">
                  ${courseRound.attrs['course_amount'].value}
                </c:when>
                <c:otherwise>
                  ${courseRound.course.hours}
                </c:otherwise>
              </c:choose>
            </td>
          </c:when>
          <c:otherwise>
            <td> ${courseRound.finished}&nbsp;/&nbsp;
              <c:choose>
                <c:when test="${not empty courseRound.attrs['course_amount']}">
                  ${courseRound.attrs['course_amount'].value}
                </c:when>
                <c:otherwise>
                  ${courseRound.course.hours}
                </c:otherwise>
              </c:choose>
            </td>
          </c:otherwise>
        </c:choose>
        
        <td><p>腹部锻炼组</p>
            <p>新学员</p>
        </td>
        <td>${courseRound.coach.name}&nbsp;/&nbsp;${courseRound.site.name}</td>
        
        <td>
          <c:choose>
            <c:when test="${courseRound.effectiveStart == null}">
              未开启<br/>
            </c:when>
            <c:otherwise>
              <fmt:formatDate value="${courseRound.effectiveStart}" pattern="yyyy-MM-dd HH:mm:ss"/><br/>
            </c:otherwise>
          </c:choose>
          <c:choose>
            <c:when test="${courseRound.holdDate != null and courseRound.courseStatus.hold}">
              <fmt:formatDate value="${courseRound.holdDate}" pattern="yyyy-MM-dd HH:mm:ss"/><br/>
            </c:when>
            <c:otherwise>
              未冻结<br/>
            </c:otherwise>
          </c:choose>
          <fmt:formatDate value="${courseRound.effectiveEnd}" pattern="yyyy-MM-dd HH:mm:ss"/>
        </td>
        
        <td>${courseRound.courseStatus.description}</td>
        <td class="text-center">
          <a href="${ctx.host}/individual-rounds/${courseRound.id}?type=info" title="课程详情">详情</a>&nbsp;&nbsp;
        </td>
      </tr>
    </c:forEach>
  </tbody>
</table>
